package br.com.fogas.webservice.repository.soap;

import android.content.Context;
import br.com.fogas.utils.exception.ParseXmlException;
import br.com.fogas.webservice.exception.ERaiseWebServiceException;
import br.com.fogas.webservice.exception.RespostaWebServiceException;
import br.com.fogas.webservice.exception.SemConexaoInternetException;
import br.com.fogas.webservice.exception.ServidorForaException;
import br.com.fogas.webservice.exception.TempoEsperaRespostaException;
import br.com.fogas.webservice.exception.WebServiceException;
import br.com.fogas.webservice.parser.visita.VisitaEnvelope;
import br.com.fogas.webservice.parser.visita.VisitaRequest;
import br.com.fogas.webservice.parser.visita.VisitaResponse;
import br.com.fogas.webservice.repository.IRepositoryHandler;
import br.com.fogas.webservice.soap.impl.VisitaSOAP;

public class VisitaRepository implements IRepositoryHandler<VisitaResponse> {

	private Context context;
	private VisitaRequest request;

	public VisitaRepository(Context context, VisitaRequest request) {
		this.context = context;
		this.request = request;
	}
	
	@Override
	public VisitaResponse getResponse() throws SemConexaoInternetException,
			ParseXmlException, TempoEsperaRespostaException,
			ServidorForaException, RespostaWebServiceException,
			WebServiceException, ERaiseWebServiceException {

		VisitaEnvelope envelope = new VisitaEnvelope();
		envelope.body.request = request;
		
		VisitaSOAP soap = new VisitaSOAP(context, envelope);
		return soap.getResponse();
	}
	
}